package com.framework.plm.bas.web.provider.impl;

import java.util.Map;

import com.framework.plm.bas.param.QueryParam;

@SuppressWarnings("unchecked")
public class HqlQueryProvider extends AbsPlmQueryProvider {

	private String queryHql = null;
	private String querySizeHql = null;
	private Map param = null;

	public HqlQueryProvider(String queryHql, String querySizeHql, Map param) {
		this.queryHql = queryHql;
		this.querySizeHql = querySizeHql;
		this.param = param;
	}

	protected QueryParam[] getQueryParam(boolean querySize) {
		int offset = getPreferPageSize() * (super.getPageSupport().getCurPageNo() - 1);
		QueryParam[] result = new QueryParam[2];
		result[0] = QueryParam.getInstance(queryHql, param,
				offset, getPreferPageSize());
		if(querySize){
			result[1] = QueryParam.getInstance(querySizeHql, param);
		}		
		return result;
	}

}
